package com.hz.ys_stock.action;


import com.hz.framework.MyAction.BaseAction;
import com.hz.framework.dao.CommonDao;
import com.hz.ys_stock.bean.PresStockspecial;
import com.hz.ys_stock.dao.StockDao;
import com.hz.ys_stock.dbsql.StockSql;

/**
 * *****************************************************************************
 *               Copyright(c) 2010 by 哈尔滨华泽数码科技有限公司.
 *                       All rights reserved.
 *******************************************************************************
 *     File Name         :  com.hz.ys_stock.action.MakingsManageAction.java
 *     Description(说明)	: 原材料管理 action
 * -----------------------------------------------------------------------------
 *     No.        Date              Revised by           Description	
 *     			  Jul 29, 2011           韩飞              Created
 *****************************************************************************
 */
public class StockAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	
	private Object pagList = null;

	/**
	 * @author 韩飞
	 * @time Nov 19, 2011	
	 * @return
	 * @throws Exception 
	 * 方法功能: 原材料管理 主料
	 */
	public String Stock_Main() throws Exception {
		boolean selflag = true;
		boolean pagflag = false;
		String rn = "";
		StockDao sd = new StockDao();
		String operate = CommonDao.isnull(request.getParameter("operate"));
//		删除信息
		if("delinfo".equals(operate)){
			sd.Del_Stock(request);
			rn = "rect";
			selflag = false;
		}
		//查看日志
		if("sellog".equals(operate)){
			pagList = sd.SelStock_log(request,"主料");
			request.setAttribute("action", "stockmain");
			rn = "sellog";
			selflag = false;
			pagflag = true;
		}
//		默认列表页面
		if(selflag){
			rn = SUCCESS;
			pagList = sd.SelStock(request,"主料");
			request.setAttribute("action", "stockmain");
			pagflag = true;
		}
//		配置分页
		if(pagflag){
			doAllSearchList(request, "listinfo", pagList, "jdbc");
		}
		
		return rn;
	}
	/**
	 * @author 韩飞
	 * @time Nov 22, 2011	
	 * @return
	 * @throws Exception 
	 * 方法功能: 原材料管理 辅料
	 */
	public String Stock_Aided() throws Exception {
		boolean selflag = true;
		boolean pagflag = false;
		String rn = "";
		StockDao sd = new StockDao();
		String operate = CommonDao.isnull(request.getParameter("operate"));
//		删除信息
		if("delinfo".equals(operate)){
			sd.Del_Stock(request);
			rn = "rect";
			selflag = false;
		}
		//查看日志
		if("sellog".equals(operate)){
			pagList = sd.SelStock_log(request,"辅料");
			request.setAttribute("action", "stockaided");
			rn = "sellog";
			selflag = false;
			pagflag = true;
		}
//		默认列表页面
		if(selflag){
			rn = SUCCESS;
			pagList = sd.SelStock(request,"辅料");
			request.setAttribute("action", "stockaided");
			pagflag = true;
		}
//		配置分页
		if(pagflag){
			doAllSearchList(request, "listinfo", pagList, "jdbc");
		}
		
		return rn;
	}
	
	
	public String listForTask() throws Exception {
		
		String source ="主料";
		String sql=StockSql.SEL_STOCK_INFO + " and makingtype='主料' ";
		request.setAttribute("source", source);
		doAllSearchList(request, "list", sql, "jdbc");
		return SUCCESS;
	
	}
	
	/**
	 * @author 韩飞
	 * @time Nov 22, 2011	
	 * @return
	 * @throws Exception 
	 * 方法功能: 特殊入库
	 */
	public String Stock_special() throws Exception {
		boolean selflag = true;
		boolean pagflag = false;
		String rn = "";
		StockDao sd = new StockDao();
		String mtp = CommonDao.isnull(request.getParameter("mtp"));//标识主料辅料  stockaided  stockmain
		String crflag = CommonDao.isnull(request.getParameter("crflag"));//标识出库入库 ck  rk
		String operate = CommonDao.isnull(request.getParameter("operate"));
//		录入页面进入
		if("inspage".equals(operate)){
			if("ck".equals(crflag)){
				request.setAttribute("crflag", "出库");
			}else{
				request.setAttribute("crflag", "入库");
			}
			if("stockaided".equals(mtp)){
				request.setAttribute("list", sd.SelStockList(request,"辅料"));
				request.setAttribute("mtp", "辅料");
			}else{
				request.setAttribute("list", sd.SelStockList(request,"主料"));
				request.setAttribute("mtp", "主料");
			}
			rn = "inspage";
			selflag = false;
		}
//		保存信息
		if("insinfo".equals(operate)){
			sd.DoSaveSpecial(ps);
			rn = "rect";
			selflag = false;
		}
//		删除信息
		if("delinfo".equals(operate)){
			sd.Del_Special(request);
			rn = "rect";
			selflag = false;
		}
//		默认列表页面
		if(selflag){
			rn = SUCCESS;
			pagList = sd.SelSpecial(request,request.getParameter("mtp"));
			pagflag = true;
		}
//		配置分页
		if(pagflag){
			doAllSearchList(request, "listinfo", pagList, "jdbc");
		}
		
		return rn;
	}
	private String mtp;
	private PresStockspecial ps = new PresStockspecial();

	public PresStockspecial getPs() {
		return ps;
	}
	public void setPs(PresStockspecial ps) {
		this.ps = ps;
	}
	public String getMtp() {
		return mtp;
	}
	public void setMtp(String mtp) {
		this.mtp = mtp;
	}
}
